#ifndef BTL_DEMO_VIDEOSOURCEDEMO_QVIDEOSOURCEDEMOAPPLICATION
#define BTL_DEMO_VIDEOSOURCEDEMO_QVIDEOSOURCEDEMOAPPLICATION

#include <QApplication>
#include <QTimer>
#include <btl/extra/VideoSource/VideoSourceV4L2.hpp>
#include <btl/extra/VideoSource/VideoSourceUEye.hpp>
#include <btl/extra/Gui/QImageView.hpp>
#include <iostream>
#include <iterator>

class QVideoSourceDemoApplication : public QApplication
{

      Q_OBJECT

   public:

      QVideoSourceDemoApplication(int& argc, char** argv, btl::extra::VideoSource* pVideoSource) : QApplication(argc, argv), _pVideoSource(pVideoSource)
      {
         _pTimer = new QTimer;
         _pView = new btl::extra::QImageViewRGB;
         _pView->show();
         connect(_pTimer, SIGNAL(timeout()), this, SLOT(update()));
         _pTimer->start(30);
      }

      ~QVideoSourceDemoApplication() {}

   protected Q_SLOTS:

      void update()
      {
         if(_pVideoSource)
         {
            btl::ImageRegionConstRGB frame = _pVideoSource->getNextFrame();
            _pView->setImage(frame);
         }
      }

   protected:

      QTimer* _pTimer;

      btl::extra::VideoSource* _pVideoSource;

      btl::extra::QImageViewRGB* _pView;

};

#endif //BTL_DEMO_VIDEOSOURCEDEMO_QVIDEOSOURCEDEMOAPPLICATION
